package com.hs.biye.controller.admin;

import com.hs.biye.constant.MessageConstant;
import com.hs.biye.excepction.BaseException;
import com.hs.biye.model.DTO.MedicineRequest;
import com.hs.biye.model.DTO.SeedoctorRequest;
import com.hs.biye.model.VO.MedicineVo;
import com.hs.biye.model.VO.SeedoctorVo;
import com.hs.biye.model.reslut.Result;
import com.hs.biye.model.reslut.ResultPage;
import com.hs.biye.service.MedicineService;
import com.hs.biye.service.SeedoctorService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/admin/see")
public class SeeDoctorController {

    @Resource
    private SeedoctorService seedoctorService;

    //查询就诊信息
    @PostMapping("/pages")
    public ResultPage<SeedoctorVo> getMedicinePage(@RequestBody SeedoctorRequest seedoctorRequest){
        if (seedoctorRequest == null){
            throw new BaseException(MessageConstant.PAR_NOT_RIGHT);
        }
        return seedoctorService.getPageSeeDoctor(seedoctorRequest);
    }


    //修改就诊
    @PostMapping("/update")
    public Result<Boolean> updateMedicine(@RequestBody SeedoctorRequest seedoctorRequest){
        if (seedoctorRequest == null){
            throw new BaseException(MessageConstant.PAR_NOT_RIGHT);
        }
        boolean result = seedoctorService.updateSeeDoctor(seedoctorRequest);

        return Result.success(result);
    }
    //添加就诊
    @PostMapping("/add")
    public Result<Boolean> addMedicine(@RequestBody SeedoctorRequest seedoctorRequest){
        if (seedoctorRequest == null){
            throw new BaseException(MessageConstant.PAR_NOT_RIGHT);
        }
        boolean result = seedoctorService.addSeeDoctor(seedoctorRequest);
        return Result.success(result);
    }

    //删除就诊
    @GetMapping("/delete/{id}")
    public Result<Boolean> deleteMedicine(@PathVariable Integer id){
        if (id == null){
            throw new BaseException(MessageConstant.PAR_NOT_RIGHT);
        }
        boolean result = seedoctorService.removeSeeDoctor(id);
        return Result.success(result);
    }

}
